home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / pinbo.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  3KB  |  129 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "common.h"
  11. #include "usrintrf.h"
  12. #include "vidhrdw/generic.h"
  13.  
  14.  
  15. static int flipscreen[2];
  16.  
  17.  
  18.  
  19. void pinbo_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom)
  20. {
  21.     int i;
  22.  
  23.  
  24.     for (i = 0;i < Machine->drv->total_colors;i++)
  25.     {
  26.         int bit0,bit1,bit2,bit3;
  27.  
  28.         /* red component */
  29.         bit0 = (color_prom[0] >> 0) & 0x01;
  30.         bit1 = (color_prom[0] >> 1) & 0x01;
  31.         bit2 = (color_prom[0] >> 2) & 0x01;
  32.         bit3 = (color_prom[0] >> 3) & 0x01;
  33.         *(palette++) =  0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  34.         /* green component */
  35.         bit0 = (color_prom[Machine->drv->total_colors] >> 0) & 0x01;
  36.         bit1 = (color_prom[Machine->drv->total_colors] >> 1) & 0x01;
  37.         bit2 = (color_prom[Machine->drv->total_colors] >> 2) & 0x01;
  38.         bit3 = (color_prom[Machine->drv->total_colors] >> 3) & 0x01;
  39.         *(palette++) =  0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  40.         /* blue component */
  41.         bit0 = (color_prom[2*Machine->drv->total_colors] >> 0) & 0x01;
  42.         bit1 = (color_prom[2*Machine->drv->total_colors] >> 1) & 0x01;
  43.         bit2 = (color_prom[2*Machine->drv->total_colors] >> 2) & 0x01;
  44.         bit3 = (color_prom[2*Machine->drv->total_colors] >> 3) & 0x01;
  45.         *(palette++) =  0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
  46.  
  47.         color_prom++;
  48.     }
  49. }
  50.  
  51. WRITE_HANDLER( pinbo_flipscreen_w )
  52. {
  53.     if (flipscreen[0] != (data & 1))
  54.     {
  55.         flipscreen[0] = data & 1;
  56.         memset(dirtybuffer,1,videoram_size);
  57.     }
  58.     if (flipscreen[1] != (data & 2))
  59.     {
  60.         flipscreen[1] = data & 2;
  61.         memset(dirtybuffer,1,videoram_size);
  62.     }
  63. }
  64.  
  65. void pinbo_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  66. {
  67.     int offs;
  68.  
  69.     /* for every character in the Video RAM, check if it has been modified */
  70.     /* since last time and update it accordingly. */
  71.     for (offs = videoram_size - 1;offs >= 0;offs--)
  72.     {
  73.         if (dirtybuffer[offs])
  74.         {
  75.             int sx,sy;
  76.  
  77.  
  78.             dirtybuffer[offs] = 0;
  79.  
  80.             sx = offs % 32;
  81.             sy = offs / 32;
  82.             if (flipscreen[0]) sx = 31 - sx;
  83.             if (flipscreen[1]) sy = 31 - sy;
  84.  
  85.             drawgfx(tmpbitmap,Machine->gfx[0],
  86.                     videoram[offs] + ((colorram[offs] & 0x70) << 5),
  87.                     colorram[offs] & 0x0f,
  88.                     flipscreen[0],flipscreen[1],
  89.                     8*sx,8*sy,
  90.                     &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  91.         }
  92.     }
  93.  
  94.     /* copy the character mapped graphics */
  95.     copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  96.  
  97.     /* Draw the sprites. */
  98.     for (offs = spriteram_size - 4;offs >= 0;offs -= 4)
  99.     {
  100.         int sx,sy,flipx,flipy;
  101.         int code,color;
  102.  
  103.  
  104.         sx = spriteram[offs + 3];
  105.         sy = 240 - spriteram[offs];
  106.         flipx = spriteram[offs+1] & 0x40;
  107.         flipy = spriteram[offs+1] & 0x80;
  108.         if (flipscreen[0])
  109.         {
  110.             sx = 240 - sx;
  111.             flipx = !flipx;
  112.         }
  113.         if (flipscreen[1])
  114.         {
  115.             sy = 240 - sy;
  116.             flipy = !flipy;
  117.         }
  118.         code = (spriteram[offs+1] & 0x3f) | 0x40 | ((spriteram[offs+2] & 0x30) << 3);
  119.         color = (spriteram[offs+2] & 0x0f);
  120.  
  121.         drawgfx(bitmap,Machine->gfx[1],
  122.                 code,
  123.                 color,
  124.                 flipx,flipy,
  125.                 sx,sy,
  126.                 &Machine->drv->visible_area,TRANSPARENCY_PEN,0);
  127.     }
  128. }
  129.